<?
function NewsPageBreak($url, $total_record, $PageSize, $CurrenPage, $main_pager = "main_pager",$main_page_btn = "main_page_btn", $not_avaiable = "not_avaiable"){
   $html_page = "";
   $first	= false;
   $preview	= false;
   $last	= false;
   $next	= false;
   if($total_record / $PageSize == 0) $num_page = $total_record / $PageSize;
   else $num_page = (int)($total_record / $PageSize) + 1;
   if($num_page > 1){
      if($CurrenPage > 1){
        $first = true;
        $preview = true; 
      } 
      if($CurrenPage < $num_page) {
         $last = true;
         $next = true;  
      }
   }
   $start   = $CurrenPage - 2;
   $end     = $CurrenPage + 2;
   if($start <= 0) $start = 1;
   if($end >= $num_page) $end = $num_page; 
   $html_page .='
   <nav class= '.$main_pager.'>
      <ul>
         <li class="'.$main_page_btn.(($first? "" : " not_avaiable")).'"><a class="vpage1">Đầu</a></li>
         <li class="'.$main_page_btn.(($preview? "" : " not_avaiable")).'"><a class="vpage'.($CurrenPage -1).'"">&lt;</a></li>';
         for($i = $start; $i<= $end; $i ++){
			    $html_page .='        
			         <li class="'.$main_page_btn.(($CurrenPage == $i)? " active" : "").'"><a class="vpage'.$i.'" >'. $i.'</a></li>';         	
			}
  	if(($CurrenPage + 2) < $num_page){   $html_page .='    
							 		<li>...<li>   
									<li class="'.$main_page_btn.'"><a class="vpage'.$num_page.'" >'. $num_page.'</a></li>';
							 }
	 $html_page .='  
         <li class="'.$main_page_btn.(($next? "" : " not_avaiable")).'"><a class="vpage'.($CurrenPage + 1).'" >&gt;</a></li>
         <li class="'.$main_page_btn.(($last? "" : " not_avaiable")).'"><a class="vpage'.$num_page.'"  >Cuối</a></li>
      </ul>
   </nav>';
   if($total_record > $PageSize)   return $html_page;
}
?>